<template>
  <div class="op-bar" ref="refBar">
    <div class="del-confirm" v-if="showDel" @click="handleConfirm">确认取消</div>
    <div class="del-item" v-else @click="showDel = true">取消关注</div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { onClickOutside } from '@vueuse/core'

const emit = defineEmits(['delete'])
const showDel = ref(false)
const refBar = ref<NullAble<HTMLElement>>(null)

onClickOutside(refBar, () => {
  showDel.value = false
})

const handleConfirm = () => {
  emit('delete')
}
</script>

<style lang="less" scoped>
.op-bar {
  flex-shrink: 0;
  width: 93px;
  height: 100%;
  display: flex;
  align-items: center;
  .del-item {
    font-size: 12px;
    color: #3a75c5;
    border-radius: 15px;
    border: 0.5px solid #3a75c5;
    padding: 5px 11px;
  }
  .del-confirm {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    background: #fa5252;
    color: #fff;
    text-align: center;
    line-height: 69px;
    font-size: 14px;
  }
}
</style>
